import web

render = web.template.render('templates')
urls = (
    # 路径匹配
    '/indexHtml','indexHtml',
    '/index','index',
    '/blog/\d+','blog',
    '/temp','temp',
    '/(.*)', 'hello'
)



app = web.application(urls, globals())

class hello:
    def GET(self, name):
        if not name:
            name = 'World'
        return 'Hello, ' + name + '!'

class index:
    def GET(self):
        return 'index'


class indexHtml:
    def GET(self):
        # 实现页面 调整  相对路径从项目下    设置编码防止乱码
        return open('study_F\web\html\index.html','r',encoding='utf-8').read()

class blog:
    def POST(self):
        # 获取请求参数
        query = web.input()
        
        return query

    def GET(self):
        #  获取请求头
        return web.ctx.env


class temp:
    def GET(self):
        print('temp')

        hello = web.template.frender('study_F\web\templates\temp.html')
        return hello('temp')

if __name__ == "__main__":
    app.run()